function dcm2Dtonii3D(directory)

% Load all images in directory and saves as one 3D nifti image
% Henk Smit

    [tstimg, info_structure] = loaddata([directory filesep], 1 , 1.5);
    tstimg = squeeze(tstimg);
    T = affineTransformFromDicominfo( info_structure );
    [nii] = make_niiT(uint16(tstimg), T);
    save_nii( nii, [directory, filesep,'3D.nii'])

end